package com.rongc.client.freight.business.mine.view.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.Checkable;
import android.widget.ImageView;

import com.rongc.client.freight.R;


/**
 * Created by Bruce on 2016/10/25.
 */
public class VisibleView extends ImageView implements Checkable {
    boolean isChecked;

    public VisibleView(Context context) {
        this(context, null);
    }

    public VisibleView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean isChecked() {
        return isChecked;
    }

    @Override
    public void setChecked(boolean checked) {
        this.isChecked = checked;
        if(isChecked){
            setImageResource(R.mipmap.login_visible);
        }else{
            setImageResource(R.mipmap.login_invisible_icon);
        }
    }

    @Override
    public void toggle() {
        setChecked(!isChecked);
    }

}
